package com.mademoisellegeek.carrentalsimulation.comparator;

import com.mademoisellegeek.carrentalsimulation.Travel;
import java.util.Comparator;

/*
 * Comparator corresponding to the END_DATE sort method
 */
public class EndDayComparator implements Comparator {

    @Override
    public int compare(Object travel1, Object travel2) {

        int endDay1 = ((Travel) travel1).getEndDay();
        int endDay2 = ((Travel) travel2).getEndDay();

        if (endDay1 > endDay2) {
            return 1;
        } else if (endDay1 < endDay2) {
            return -1;
        } else {
            return 0;
        }
    }
}